package com.jk.common.config;

import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 读取项目相关配置
 *
 * @author happy
 */

@Getter
@Setter
@Configuration
@ConfigurationProperties(prefix = "app")
public class AppConfig {
    /**
     * 项目名称
     */
    private String name;

    /**
     * 版本
     */
    private String version;

    /**
     * 版权年份
     */
    private String copyrightYear;

    private String elUrlPrefix;

    private String jboxUrlPrefix;

    /**
     * 实例演示开关
     */
    private boolean demoEnabled;

    private boolean serverLogEnabled;

    private List<String> whiteList;

    private List<String> whiteDomain;

    private String domain;
    /**
     * 上传路径
     */
    private static String profile;


    private static String dataRoot;

    private static String startPcReader;

    private static String stopPcReader;
    /**
     * 获取地址开关
     */
    private static boolean addressEnabled;


    /**
     * 是否满箱生成清检单
     */
    private static boolean isGenerateInspectionCheck;

    /**
     * iv工序自动过站时，是否自动更新组件等级分档信息
     */
    private static boolean isAutoUpdateModuleInfo;

    /**
     * 工装追溯iv工序自动过站时，是否自动更新工装追溯的绑定组件状态
     */
    private static boolean isAutoUpdatePanelStatusInfo;



    /**
     * 唛头打印 excel生成目录 以及 sn图片生成目录
     */
    private static String printFilePath;

    public static String getPrintFilePath() {
        return printFilePath;
    }

    public static String getTemplatePrefix() {
        return getDataRoot() + "/template";
    }

    public void setPrintFilePath(String printFilePath) {
        AppConfig.printFilePath = printFilePath;
    }

    public static boolean getIsGenerateInspectionCheck() {
        return isGenerateInspectionCheck;
    }

    public void setIsGenerateInspectionCheck(boolean isGenerateInspectionCheck) {
        AppConfig.isGenerateInspectionCheck = isGenerateInspectionCheck;
    }


    public static boolean getIsAutoUpdateModuleInfo() {
        return isAutoUpdateModuleInfo;
    }

    public void setIsAutoUpdateModuleInfo(boolean isAutoUpdateModuleInfo) {
        AppConfig.isAutoUpdateModuleInfo = isAutoUpdateModuleInfo;
    }

    public static boolean getIsAutoUpdatePanelStatusInfo() {
        return isAutoUpdatePanelStatusInfo;
    }

    public void setIsAutoUpdatePanelStatusInfo(boolean isAutoUpdatePanelStatusInfo) {
        AppConfig.isAutoUpdatePanelStatusInfo = isAutoUpdatePanelStatusInfo;
    }
    /**
     * 验证码类型
     */
    private static String captchaType;


    public void setDataRoot(String dateRoot) {
        AppConfig.dataRoot = dateRoot;
    }

    public static String getDataRoot() {
        return dataRoot;
    }

    public void setStartPcReader(String startPcReader) {
        AppConfig.startPcReader = startPcReader;
    }

    public static String getStartPcReader() {
        return startPcReader;
    }

    public void setStopPcReader(String stopPcReader) {
        AppConfig.stopPcReader = stopPcReader;
    }

    public static String getStopPcReader() {
        return stopPcReader;
    }


    public void setProfile(String profile) {
        AppConfig.profile = profile;
    }

    public void setAddressEnabled(boolean addressEnabled) {
        AppConfig.addressEnabled = addressEnabled;
    }

    public void setCaptchaType(String captchaType) {
        AppConfig.captchaType = captchaType;
    }

    public static String getProfile() {
        return profile;
    }


    public static boolean isAddressEnabled() {
        return addressEnabled;
    }

    public static String getCaptchaType() {
        return captchaType;
    }


    /**
     * 获取导入上传路径
     */
    public static String getImportPath() {
        return getProfile() + "/import";
    }

    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath() {
        return getProfile() + "/avatar";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath() {
        return getProfile() + "/download/";
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath() {
        return getProfile() + "/upload";
    }


    public static String getProfilePathUploadPath(String profilePath) {


        // 获取基础路径
        String profile = getProfile();

        // 判断是否以 "/" 开头并拼接
        return profile + (profilePath.startsWith("/") ? profilePath : "/" + profilePath);

    }

}
